package main

import "fmt"

type Point struct{ x, y int }

type Circle struct {
	Point
	Radis int
}

type Wheel struct {
	Circle
	Spokes int
}

func main() {
	point := Point{1, 2}
	fmt.Println(point)

	point2 := Point{x: 3, y: 4}
	fmt.Println(point2)

	point3 := Point{x: 1, y: 2}
	fmt.Println(point == point2)
	fmt.Println(point == point3)

	fmt.Println(*scale(point3, 5))

	w := Wheel{Circle{Point{8, 8}, 5}, 20}
	fmt.Println(w.x)
	fmt.Println(w.y)
	fmt.Println(w.Radis)
	fmt.Println(w.Spokes)
}

// 出于效率考虑，大型结构体从函数中返回，通常返回指针或地址，避免发生复制，影响效率
func scale(point Point, factor int) *Point {
	return &Point{point.x * factor, point.y * factor}
}
